public class Solution26 {
    public static int removeDuplicates(int[] nums) {
        int p = 0;
        for (int i = 0; i < nums.length-1; i++) {
            if (nums[i]== nums[i+1]) continue;
            nums[p] = nums[i];
            p++;
        }
        return p + 1;
    }

    public static void main(String[] args) {
        System.out.println(removeDuplicates(new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4}));
    }
}
